package com.huawei.hwid.core.d;

import com.huawei.hwid.core.d.b.e;
import java.lang.reflect.InvocationTargetException;

public class i {
    private static void a(Class cls, Class[] clsArr, Object[] objArr) throws Exception {
        if (cls == null) {
            throw new Exception("class is null in staticFun");
        } else if (clsArr == null) {
            if (objArr != null) {
                throw new Exception("paramsType is null, but params is not null");
            }
        } else if (objArr == null) {
            throw new Exception("paramsType or params should be same");
        } else if (clsArr.length != objArr.length) {
            throw new Exception("paramsType len:" + clsArr.length + " should equal params.len:" + objArr.length);
        }
    }

    public static Object a(Class cls, String str, Class[] clsArr, Object[] objArr) throws Exception {
        Object obj = null;
        a(cls, clsArr, objArr);
        try {
            try {
                obj = cls.getMethod(str, clsArr).invoke(null, objArr);
            } catch (IllegalAccessException e) {
                e.e("HwInvoke", "IllegalAccessException", true);
            } catch (IllegalArgumentException e2) {
                e.e("HwInvoke", "IllegalArgumentException", true);
            } catch (InvocationTargetException e3) {
                e.e("HwInvoke", "InvocationTargetException", true);
            }
        } catch (NoSuchMethodException e4) {
            e.e("HwInvoke", "NoSuchMethodException", true);
        } catch (Exception e5) {
            e.e("HwInvoke", "Exception", true);
        }
        return obj;
    }

    public static Object a(String str, String str2, Class[] clsArr, Object[] objArr) {
        try {
            return a(Class.forName(str), str2, clsArr, objArr);
        } catch (ClassNotFoundException e) {
            e.e("HwInvoke", "ClassNotFoundException", true);
            return null;
        } catch (Exception e2) {
            e.e("HwInvoke", "Exception", true);
            return null;
        } catch (Throwable th) {
            e.e("HwInvoke", "Throwable", true);
            return null;
        }
    }

    public static Object a(Class<?> cls, Object obj, String str, Class<?>[] clsArr, Object[] objArr) throws Exception {
        a(cls, clsArr, objArr);
        try {
            try {
                return cls.getMethod(str, clsArr).invoke(obj, objArr);
            } catch (IllegalAccessException e) {
                e.e("HwInvoke", "IllegalAccessException", true);
                return null;
            } catch (IllegalArgumentException e2) {
                e.e("HwInvoke", "IllegalArgumentException", true);
                return null;
            } catch (InvocationTargetException e3) {
                e.e("HwInvoke", "InvocationTargetException", true);
                return null;
            }
        } catch (NoSuchMethodException e4) {
            throw e4;
        } catch (Exception e5) {
            e.e("HwInvoke", "Exception", true);
        }
    }
}
